package b.b.h;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.ColorFilter;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.util.Log;

/* compiled from: AppCompatDrawableManager */
public final class e {
    public static final Mode b = Mode.SRC_IN;
    public static e c;
    public v a;

    /* compiled from: AppCompatDrawableManager */
    public class a implements b.b.h.v.e {
        public final int[] a = new int[]{2131230920, 2131230918, 2131230837};
        public final int[] b = new int[]{2131230861, 2131230902, 2131230868, 2131230863, 2131230864, 2131230867, 2131230866};
        public final int[] c = new int[]{2131230917, 2131230919, 2131230854, 2131230910, 2131230911, 2131230913, 2131230915, 2131230912, 2131230914, 2131230916};
        public final int[] d = new int[]{2131230892, 2131230852, 2131230891};
        public final int[] e = new int[]{2131230908, 2131230921};
        public final int[] f = new int[]{2131230840, 2131230846, 2131230841, 2131230847};

        public final boolean a(int[] iArr, int i) {
            for (int i2 : iArr) {
                if (i2 == i) {
                    return true;
                }
            }
            return false;
        }

        public final ColorStateList b(Context context, int i) {
            r1 = new int[4][];
            r0 = new int[4];
            int c = a0.c(context, 2130968776);
            int b = a0.b(context, 2130968774);
            r1[0] = a0.b;
            r0[0] = b;
            r1[1] = a0.d;
            r0[1] = b.i.d.a.a(c, i);
            r1[2] = a0.c;
            r0[2] = b.i.d.a.a(c, i);
            r1[3] = a0.f;
            r0[3] = i;
            return new ColorStateList(r1, r0);
        }

        public ColorStateList c(Context context, int i) {
            if (i == 2131230857) {
                return b.b.d.a.a.a(context, 2131099669);
            }
            if (i == 2131230907) {
                return b.b.d.a.a.a(context, 2131099672);
            }
            if (i == 2131230906) {
                int[][] iArr = new int[3][];
                int[] iArr2 = new int[3];
                ColorStateList d = a0.d(context, 2130968792);
                if (d == null || !d.isStateful()) {
                    iArr[0] = a0.b;
                    iArr2[0] = a0.b(context, 2130968792);
                    iArr[1] = a0.e;
                    iArr2[1] = a0.c(context, 2130968775);
                    iArr[2] = a0.f;
                    iArr2[2] = a0.c(context, 2130968792);
                } else {
                    iArr[0] = a0.b;
                    iArr2[0] = d.getColorForState(iArr[0], 0);
                    iArr[1] = a0.e;
                    iArr2[1] = a0.c(context, 2130968775);
                    iArr[2] = a0.f;
                    iArr2[2] = d.getDefaultColor();
                }
                return new ColorStateList(iArr, iArr2);
            } else if (i == 2131230845) {
                return b(context, a0.c(context, 2130968774));
            } else {
                if (i == 2131230839) {
                    return b(context, 0);
                }
                if (i == 2131230844) {
                    return b(context, a0.c(context, 2130968771));
                }
                if (i == 2131230904 || i == 2131230905) {
                    return b.b.d.a.a.a(context, 2131099671);
                }
                if (a(this.b, i)) {
                    return a0.d(context, 2130968777);
                }
                if (a(this.e, i)) {
                    return b.b.d.a.a.a(context, 2131099668);
                }
                if (a(this.f, i)) {
                    return b.b.d.a.a.a(context, 2131099667);
                }
                return i == 2131230901 ? b.b.d.a.a.a(context, 2131099670) : null;
            }
        }

        public final void d(Drawable drawable, int i, Mode mode) {
            if (o.a(drawable)) {
                drawable = drawable.mutate();
            }
            if (mode == null) {
                mode = e.b;
            }
            drawable.setColorFilter(e.c(i, mode));
        }
    }

    public static synchronized e a() {
        e eVar;
        synchronized (e.class) {
            if (c == null) {
                e();
            }
            eVar = c;
        }
        return eVar;
    }

    public static synchronized PorterDuffColorFilter c(int i, Mode mode) {
        PorterDuffColorFilter h;
        synchronized (e.class) {
            h = v.h(i, mode);
        }
        return h;
    }

    public static synchronized void e() {
        synchronized (e.class) {
            if (c == null) {
                e eVar = new e();
                c = eVar;
                eVar.a = v.d();
                v vVar = c.a;
                a aVar = new a();
                synchronized (vVar) {
                    vVar.g = aVar;
                }
            }
        }
    }

    public static void f(Drawable drawable, d0 d0Var, int[] iArr) {
        Mode mode = v.h;
        if (!o.a(drawable) || drawable.mutate() == drawable) {
            boolean z = d0Var.d;
            if (z || d0Var.c) {
                ColorFilter colorFilter = null;
                ColorStateList colorStateList = z ? d0Var.a : null;
                Mode mode2 = d0Var.c ? d0Var.b : v.h;
                if (!(colorStateList == null || mode2 == null)) {
                    colorFilter = v.h(colorStateList.getColorForState(iArr, 0), mode2);
                }
                drawable.setColorFilter(colorFilter);
            } else {
                drawable.clearColorFilter();
            }
            if (VERSION.SDK_INT <= 23) {
                drawable.invalidateSelf();
                return;
            }
            return;
        }
        Log.d("ResourceManagerInternal", "Mutated drawable is not the same instance as the input.");
    }

    public synchronized Drawable b(Context context, int i) {
        return this.a.f(context, i);
    }

    public synchronized ColorStateList d(Context context, int i) {
        return this.a.i(context, i);
    }
}
